Skip to content

impl(quota-plane): stage-3 S6 — re-weighting proposal generator: evidence-packed PRs, PR-only write path - #12762

Merged
dezren39 merged 3 commits into
mainfrom
felix/12700-reweight-proposals
Nov 23, 2026
Merged

dezren39 merged 3 commits into
mainfrom
felix/12700-reweight-proposals

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Refs #12700 (slice S6 of epic #12694; design D5). Unmerged — for Felix's review.

What this is

The Stage-3 re-weighting proposal generator: the mechanism by which forecast evidence becomes config change only as a pull request (D5 — never silent edits).

  • src/quota-reweight.ts (pure, no I/O): examines S2's accuracy ledger and produces proposals + named evidence gaps. Two v1 classes:
    • pool-weight: inside a weighted-selection route, shift weight from a member whose binding window walls systematically early (precision ≥ 0.9, recall ≤ 0.7, median signed wall error ≥ +12h, ≥ 100 scored forecasts) to the member with the strongest headroom evidence; total route weight preserved.
    • caution-margin: weekly walls arriving systematically early across ≥ 2 pools (≥ 1 precision anchor, no strong counter-evidence) → propose widening NEAR_PCT one step (the margin class D4 reserves to this mechanism).
  • src/quota-reweight-pr.ts: the PR-only write path. Every subprocess passes one choke point validated against an allowlist — gh pr create / pr list, and git pushes only to quota-proposal/… branches. There is no merge call in its vocabulary; the edit itself is an exact find/replace that must match exactly once or it refuses.
  • scripts/quota-reweight-proposals.ts (package script proposals:quota-reweight, strict argv per Design: unknown means stop — one strict argument contract for the repo's operator scripts #3352): draft mode writes per-proposal proposal.json / proposal.md (the evidence pack) / change.patch plus a run report.md (proposals AND gaps); --open-prs opens the PRs.

Evidence discipline (S2's rules, binding)

Unscoreable windows never ground a proposal — the gap carries S2's reasons verbatim. Undefined precision/recall is never read as a number. Volume gates: ≥ 100 scored forecasts, ≥ 20 wall samples. The bare opencode-go pool is excluded in every window (S2's mixing artifact; per-workspace rows only) and the exclusion is itself reported with its numbers.

Demonstration on the real evidence (sandbox venue)

Run against the S2 backtest ledger (20,663 records, 2026-10-20 → 2026-11-23) and the live route config:

Evidence for this PR

  • Fail-before: the two new suites copied onto pristine origin/main fail (module absent, 0 pass / 2 errors).
  • Pass-after (sandbox): bun test quota-reweight 19/19 (incl. refusal tests: unscoreable-with-S2's-reason, insufficient volume, undefined metrics, aggregate-pool exclusion, counter-evidence; allowlist tests refusing pr merge and push-to-main before anything runs; a fake-runner drive of the full branch+edit+push+create sequence). Neighbours quota-forecast/quota-shadow-placement/quota-anomaly 60/60. tsc --noEmit clean.
  • No new dependencies.

What changes when live rows flow

Nothing in the generator. Its contract is the S2 ledger shape: today the input is the backtest's --ledger-out; once the laptop aggregator is rebuilt and live ticks accumulate, S7's scoring produces the same ledger from live forecast rows, and --forecast / --shadow join the pack from the state dir (their absence is named in the pack until then, as PR #12761's body shows). No schedule is created here — the weekly cadence is S7's (#12701), which will call this generator; that is also when the fleet-schedule-registry entry lands.


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ence-packed PRs, PR-only write path (#12700)

Pure generator (src/quota-reweight.ts) over S2's accuracy ledger: two proposal classes (pool-weight shifts inside weighted routes; caution-margin widening from weekly calibration), with named evidence gaps wherever the record cannot ground a change — unscoreable windows carry S2's reasons verbatim, thin series fail the volume gates, and the bare opencode-go pool is excluded as S2's mixing artifact. The PR-only runner (src/quota-reweight-pr.ts) routes every subprocess through an allowlist choke point: gh pr create/list and proposal-branch pushes only — no merge exists in its vocabulary. CLI (scripts/quota-reweight-proposals.ts, strict argv #3352) drafts proposals + report, or opens the PRs with --open-prs. First generated proposal: PR #12761 (NEAR_PCT 85 -> 90), opened by the generator against the S2 backtest ledger.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 01:37
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 864e751d-c98f-4273-8cce-c71c5914cccb
Commits

Reviewing files that changed from the base of the PR and between 8f07c02 and 0c65353.

Files selected for processing: 6

  • pm-stack/aggregator/package.json
  • pm-stack/aggregator/scripts/quota-reweight-proposals.ts
  • pm-stack/aggregator/src/quota-reweight-pr.test.ts
  • pm-stack/aggregator/src/quota-reweight-pr.ts
  • pm-stack/aggregator/src/quota-reweight.test.ts
  • pm-stack/aggregator/src/quota-reweight.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

felix added 2 commits November 23, 2026 01:44
… wall error (#12700)

The generator proposed NEAR_PCT 85 -> 90 on evidence that weekly
walls arrive systematically EARLY (positive median signed wall
error). But a pool reads near at windowPercent >= NEAR_PCT
(derive.ts), so raising the threshold enters caution LATER and
narrows the band — the opposite of the proposal's rationale
(Felix's review of the closed proposal PR #12761).

The caution-margin class now derives the step direction from
the sign of the grounding pools' median signed wall error:
early walls (positive) step the threshold DOWN (85 -> 80,
caution entered at a lower measured percent, earlier in the
window); late walls (negative) step it UP. Both sides are
gated identically (breadth >= 2, >= 1 precision anchor, volume
gates); counter-evidence on the opposite side at any volume —
materially disagreeing signs — is the named
counter-evidence-present gap, never a proposal. A symmetric
floor (MARGIN_MIN_PCT = 50, gap margin-at-floor) joins the
existing ceiling. Step language states the mechanism (enters
caution at a lower/higher measured percent); the word widen
is gone. Tests pin all three outcomes: positive -> down,
negative -> up, mixed -> gap, plus both bounds.
@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
event: review defect fixed on this branch
by: agent felix (kind muse, Muse sandbox seat)
at: 2026-11-22

The caution-margin direction defect from the review of #12761 is fixed here (commit 652af2f; origin/main merged in, head 0c65353):

@dezren39
dezren39 merged commit 0c9827b into main Nov 23, 2026
1 check passed
@dezren39
dezren39 deleted the felix/12700-reweight-proposals branch November 23, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant